#include "drv_timer.h"

TIM_HandleTypeDef    htimer1;
TIM_HandleTypeDef    htimer3;

extern void APP_ErrorHandler(void);

void timer_config(void)
{
  __HAL_RCC_TIM3_CLK_ENABLE();                         
  HAL_NVIC_SetPriority(TIM3_IRQn, 0, 0);               
  HAL_NVIC_EnableIRQ(TIM3_IRQn);                       
								
  htimer3.Instance = TIM3;                                          
  htimer3.Init.Period            = SystemCoreClock / 1000000 - 1;   
  htimer3.Init.Prescaler         = 1000 - 1;                        
  htimer3.Init.ClockDivision     = TIM_CLOCKDIVISION_DIV1;          
  htimer3.Init.CounterMode       = TIM_COUNTERMODE_UP;              
  htimer3.Init.RepetitionCounter = 1 - 1;                           
  htimer3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;  

  if (HAL_TIM_Base_Init(&htimer3) != HAL_OK)                        
  {
    APP_ErrorHandler();
  }

  if (HAL_TIM_Base_Start_IT(&htimer3) != HAL_OK)                     
  {
    APP_ErrorHandler();
  }
}
